package juc.base;

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;

public class OnlyMain {

    public static void main(String[] args) throws Exception {
        /*jvm虚拟机线程系统管理接口*/
        ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
//        不要同步的monitor和sychronized信息，只获取线程及堆栈信息
        ThreadInfo[] threadInfos = threadMXBean.dumpAllThreads(false, false);
        for (ThreadInfo threadInfo : threadInfos) {
            System.out.println(threadInfo.getThreadId() + "-->" + threadInfo.getThreadName());
        }
    }
}